package com.mallcai.bigdata.ladon.service.report.impl;

import com.mallcai.bigdata.ladon.service.report.IMetaRefreshService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.event.TransactionPhase;
import org.springframework.transaction.event.TransactionalEventListener;

/**
 * @author feixy
 * @version 1.0
 * @date 2019-09-05 17:30
 */
@Component
@Slf4j
public class TransactionalMessageListener {

    @Autowired
    private IMetaRefreshService iMetaRefreshService;
    /**
     * AFTER_COMMIT是事务提交后执行，默认就是这个
     * @param metaRefreshEvent
     * @throws Exception
     */
    @TransactionalEventListener(fallbackExecution = true,phase= TransactionPhase.AFTER_COMMIT)
    public void handleMessageSend(MetaRefreshEvent metaRefreshEvent) throws Exception{
        iMetaRefreshService.publishEvent(metaRefreshEvent);
    }
}
